package com.chb.microservice.provider.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.chb.microservice.provider.hystrix.UserHystrixWrapped;

import io.swagger.annotations.Api;

/**
 * 
 * ClassName: AServiceController<br>
 * Description: TODO controller.<br>
 * 
 * @author dengw
 * @date: 2017年3月6日 下午3:17:15
 * @version V1.0
 * @since JDK 1.8
 */
@RefreshScope
@RestController
@Api("用户")
//@RequestMapping("/v1/app/user")
public class UserController {

	
	@Autowired
	private UserHystrixWrapped userHystrixWrapped;
	
	@Autowired
	DiscoveryClient discoveryClient;

	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public String login() {
		ServiceInstance serviceInstance = discoveryClient.getLocalServiceInstance();
		StringBuffer sb = new StringBuffer();
		sb.append("serviceId:" + serviceInstance.getServiceId());
		sb.append("host:" + serviceInstance.getHost());
		sb.append("port:" + serviceInstance.getPort());
		return userHystrixWrapped.login()+sb.toString();
	}
}
